package com.brzjomo.secretiveworld.util;

import com.brzjomo.secretiveworld.SecretiveWorld;
import com.brzjomo.secretiveworld.init.ModDimensionTypes;
import com.brzjomo.secretiveworld.world.dimension.resourse.ModDimResLocation;

import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.event.world.RegisterDimensionsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;

@Mod.EventBusSubscriber(modid = SecretiveWorld.MODID, bus = Bus.FORGE)
public class ForgeEventBusSubscriber {

	@SubscribeEvent
	public static void registerDimensions(final RegisterDimensionsEvent event) {
		for (int i = 0; i < ModDimResLocation.MOD_DIM_RES.length; i++) {
			if (DimensionType.byName(ModDimResLocation.MOD_DIM_RES[i]) == null) {
				if (ModDimResLocation.MOD_DIM_RES[i] == ModDimResLocation.TEST_DIM) {
					DimensionManager.registerDimension(ModDimResLocation.MOD_DIM_RES[i],
							ModDimensionTypes.TEST_DIMENSION.get(), null, true);
				}else if(ModDimResLocation.MOD_DIM_RES[i] == ModDimResLocation.SPIRIT_DIM) {
					DimensionManager.registerDimension(ModDimResLocation.MOD_DIM_RES[i],
							ModDimensionTypes.SPIRIT_DIMENSION.get(), null, true);
				}
			}
		}

		SecretiveWorld.LOGGER.info("Dimensions Registered!");
	}

}
